<%@ page session="true" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<%@ include file="header.inc"%>

<f:view>
	<h:form id="schedulerForm">
		<h:panelGroup>

			<t:div styleClass="topheader">
				<h2>.ocumed - web</h2>
			</t:div>
			
			<t:div styleClass="info">
			 <h:panelGrid columns="1">
			   <h:outputText value="Benutzer: #{wScheduler.session.patient}" />
			   <h:outputText value="Arzt: #{wScheduler.session.arzt}" />
			   </h:panelGrid> 
			</t:div>

			<t:div styleClass="navigation">

				<h:panelGrid columns="1">
				
				  
				  
				  <%--
				  <t:collapsiblePanel title="test" >
				    <h:panelGrid columns="1">
		          <h:outputText value="#{wScheduler.model.selectedDate}"></h:outputText>
	          </h:panelGrid>
				  </t:collapsiblePanel>
				  --%>
				  				
          <%-- as popup
            <t:inputCalendar 
                id="secondOne" 
                monthYearRowClass="yearMonthHeader" 
                weekRowClass="weekHeader" 
                popupButtonStyleClass="standard_bold"
                currentDayCellClass="currentDayCell" 
                value="#{wScheduler.model.selectedDate}" 
                renderAsPopup="true"
                popupTodayString="#{example_messages['popup_today_string']}" 
                popupWeekString="#{example_messages['popup_week_string']}"
                valueChangeListener="#{wScheduler.refresh}"
                 
                helpText="MM/DD/YYYY"/>
            <h:inputText value="#{calendarBean.text}"/>
          --%>

					<t:inputCalendar id="scheduleNavigator"
						currentDayCellClass="currentday" weekRowClass="week"
						monthYearRowClass="month" title="Kalender" dayCellClass="day"
						valueChangeListener="#{wScheduler.dayChange}"
						value="#{wScheduler.model.selectedDate}" />
										  				  
				  <t:collapsiblePanel title="Termin ausmachen" styleClass="panel" rendered="#{wScheduler.renderNewAppointment}">
				    <h:panelGrid columns="1">
				    
					    <t:popup id="x"
	                styleClass="popup"
	                closePopupOnExitingElement="true"
	                closePopupOnExitingPopup="true"
	                displayAtDistanceX="#{wScheduler.popupXOffset}"
	                displayAtDistanceY="#{wScheduler.popupYOffset}" >
	                <h:outputText value="#{wScheduler.selectedAppointment}" styleClass="selectedAppointment" />
	                <f:facet name="popup">
	                    <h:panelGroup>
	                        <h:panelGrid columns="1" >
	                        <h:outputText value="Bitte wählen Sie einen neuen Termin im Kalender" styleClass="userAction" />
	                        </h:panelGrid>
	                    </h:panelGroup>
	                </f:facet>
	            </t:popup>

							<h:selectOneMenu onchange="this.form.submit()"
								valueChangeListener="#{wScheduler.refreshEvent}"
								value="#{wScheduler.appointmentType}">
								
								<t:selectItems value="#{wScheduler.appointmentTypes}" var="t"
									itemLabel="#{t.display}" itemValue="#{t.id}" />
							</h:selectOneMenu>

							<h:selectOneListbox onchange="this.form.submit()"
							  valueChangeListener="#{wScheduler.useSuggestion}"
								value="#{wScheduler.suggestion}" >

								<t:selectItems value="#{wScheduler.suggestions}" var="s"
									itemLabel="#{s.display}" itemValue="#{s.id}" />
							</h:selectOneListbox>

							<h:commandButton action="#{wScheduler.newAppointment}"
	               value="Termin ausmachen" />
				    </h:panelGrid>
				  </t:collapsiblePanel>
						
          <t:collapsiblePanel title="Termin verschieben" styleClass="panel" rendered="#{wScheduler.renderMoveAppointment}" > 
            <h:panelGrid columns="1">
            
              <h:outputText value="#{wScheduler.selectedAppointment}" styleClass="selectedAppointment" />
            
		          <h:commandButton action="#{wScheduler.moveAppointment}"
		            value="Termin verschieben" />
            </h:panelGrid>
          </t:collapsiblePanel>
          
          <t:collapsiblePanel title="Termin löschen"  styleClass="panel" rendered="#{wScheduler.renderDeleteAppointment}"> 
            <h:panelGrid columns="1">
            
		          <h:commandButton action="#{wScheduler.deleteAppointment}"
		            value="Termin löschen" />
            
            </h:panelGrid>
          </t:collapsiblePanel>
          
          <t:collapsiblePanel title="Zukünftige Termine" styleClass="panel">

              <t:dataList
					        styleClass="standardList"
					        var="appointment"
					        value="#{wScheduler.appointments}"
					        layout="unorderedList" forceId="true">
					        <h:outputText value="#{appointment.time}" />
					    </t:dataList>
          </t:collapsiblePanel>
            
				</h:panelGrid>

			</t:div>

			<t:div styleClass="schedule">
			
			  <%--entryRenderer="#{wEntryRenderer}"--%>
			
				<t:schedule
				  selectedEntryClass="ocumedselectedentry"
          entryClass="ocumedentry"
				  evenClass="ocumedevenrow"
				  unevenClass="ocumedunevenrow" 

				  freeClass="ocumedfree"
				  headerClass="ocumedheader"
				  
				  value="#{wScheduler.model}" 
				  id="schedule1"
					rendered="true" 
					visibleEndHour="#{wScheduler.vend}" visibleStartHour="#{wScheduler.vbegin}"
					workingEndHour="#{wScheduler.wend}" workingStartHour="#{wScheduler.wbegin}"
					readonly="false" 
					tooltip="true" 
					theme="evolution" 
					submitOnClick="true"
					mouseListener="#{wScheduler.scheduleIt}"
					headerDateFormat="#{wScheduler.headerDateFormat}" />
			</t:div>

		</h:panelGroup>
	</h:form>
</f:view>

<%@ include file="footer.inc"%>